package com.toune.movie.mvp.adapter;

import android.support.annotation.Nullable;
import android.widget.RadioButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.toune.movie.R;
import com.toune.movie.vo.VarietyDetailVo;
import com.toune.movie.vo.VarietyVo;

import java.util.List;

public class AdapterButtonHor extends BaseQuickAdapter<VarietyVo, BaseViewHolder> {
    public AdapterButtonHor(int layoutResId, @Nullable List<VarietyVo> data) {
        super(layoutResId, data);
    }

    private int selectedPosition = -1;

    public void setSelectedPosition(int position) {
        selectedPosition = position;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, VarietyVo item) {
        RadioButton radioButton = helper.getView(R.id.radio_button);
        helper.setText(R.id.radio_button, item.getTitle());
        if (selectedPosition == helper.getLayoutPosition()) {
            radioButton.setChecked(true);
        } else {
            radioButton.setChecked(false);
        }
    }
}
